package com.ts.animal.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import com.ts.animal.dao.HeartbeatRecordDao;
import com.ts.animal.domain.HeartbeatRecordDO;
import com.ts.animal.service.HeartbeatRecordService;
import com.ts.common.utils.Result;


@Service
public class HeartbeatRecordServiceImpl implements HeartbeatRecordService {
	@Autowired
	private HeartbeatRecordDao heartbeatRecordDao;
	
	@Override
	public HeartbeatRecordDO get(Integer id){
		return heartbeatRecordDao.get(id);
	}
	
	@Override
	public List<HeartbeatRecordDO> list(Map<String, Object> map){
		return heartbeatRecordDao.list(map);
	}
	
	@Override
	public int count(Map<String, Object> map){
		return heartbeatRecordDao.count(map);
	}
	
	@Override
	public int save(Result result,HeartbeatRecordDO heartbeatRecord){
		 int ret = heartbeatRecordDao.save(heartbeatRecord);
		if(ret==0){
	    	result.set(Result.FAIL, "保存失败", null);
	    }
		return ret;
		
		
	}
	
	@Override
	public int update(Result result,HeartbeatRecordDO heartbeatRecord){
	    int ret = heartbeatRecordDao.update(heartbeatRecord);
		if(ret==0){
	    	result.set(Result.FAIL, "更新失败", null);
	    }
		return ret;
	}
	
	@Override
	public int remove(Result result,Integer id){
	    int ret = heartbeatRecordDao.remove(id);
	    if(ret==0){
	    	result.set(Result.FAIL, "删除失败", null);
	    }
		return ret;
	}
	
	@Override
	public int batchRemove(Result result,Integer[] ids){
		int ret = heartbeatRecordDao.batchRemove(ids);
		 if(ret!=ids.length){
	    	result.set(Result.FAIL, "部分删除失败", null);
	    }
		return ret;
	}
	
}
